package com.bw.kanjia.controller;

import java.util.Arrays;
import java.util.Map;

import com.bw.kanjia.entity.KanjiaActivityEntity;
import com.bw.kanjia.service.KanjiaActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.bw.kanjia.entity.KanjiaItemEntity;
import com.bw.kanjia.service.KanjiaItemService;
import com.bw.common.utils.PageUtils;
import com.bw.common.utils.R;



/**
 * 
 *
 * @author jwcz
 * @email 2898807664@qq.com
 * @date 2022-03-16 20:08:05
 */
@RestController
@RequestMapping("kanjia/kanjiaitem")
public class KanjiaItemController {
    @Autowired
    private KanjiaItemService kanjiaItemService;


    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = kanjiaItemService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/add")
    public R add(@RequestParam("id") Integer id,
                 @RequestParam("userid")String userid){
        return kanjiaItemService.add(id,userid);
    }
    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
        KanjiaItemEntity kanjiaItem = kanjiaItemService.getById(id);

        return R.ok().put("kanjiaItem", kanjiaItem);
    }
    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody KanjiaItemEntity kanjiaItem){
		kanjiaItemService.save(kanjiaItem);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody KanjiaItemEntity kanjiaItem){
		kanjiaItemService.updateById(kanjiaItem);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		kanjiaItemService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
